﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
</head>
<body style="background-color: white;">
    <section class="container-fluid" style="background-color: white;">
        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <input type="hidden" name="orderNo">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="wd100 control-label">改变公司：</label>
                        <div class="wd100 m15_l">
                            <select class="" name="companyId"></select>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </section>

    <script type="text/javascript">
        var orderNo,OriginalCompanyId;

        $(function () {
            orderNo = FlashPay.Util.GetQueryString("orderNo");
            OriginalCompanyId = FlashPay.Util.GetQueryString("OriginalCompanyId");
            init();
        });

        function init() {

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Role/GetCompany",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    cover.Remove();

                    $("select[name='companyId']").append("<option value=''>请选择</option>");

                    $.each(res.data, function (i, item) {
                        if (item.companyID == OriginalCompanyId) {
                            $("select[name='companyId']").append("<option value='" + item.companyID + "' selected>" + item.companyName + "</option >");
                        } else {
                            $("select[name='companyId']").append("<option value='" + item.companyID + "'>" + item.companyName + "</option >");
                        }
                    });

                },
                error: function (e) {
                    cover.Remove();

                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试！");
                }
            });
        }

        function save() {


            FlashPay.Util.Ajax({
                url: '/Payment/ChangeCompany',
                type: 'POST',
                data: {
                    orderNo: orderNo,
                    companyId: $("select[name='companyId']").val()
                },
                success: function (response) {
                    if (response.success) {
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        FlashPay.UI.Tip_short_warning("操作失败！" + response.errorMessage);
                    }
                },
                error: function (json) {
                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试!");
                }
            });

        }
    </script>
</body>
</html>